
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>MyBatis自带的连接池有了解过吗？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>MyBatis自带的连接池有了解过吗？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">MyBatis中的`UnpooledDataSource`是什么？它适合在生产环境中使用吗？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`org.apache.ibatis.datasource.unpooled.UnpooledDataSource`是MyBatis提供的一个简单的、非线程安全的、非池化的数据源实现。它主要用于演示和轻量级用途，并不适合在生产环境中使用。</div>
          </div>
          <div class="card-source">来源: 文档首段及「1. UnpooledDataSource 概述」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">`UnpooledDataSource`的核心工作机制是什么？这与传统的连接池有何不同？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">其核心机制是“非池化”，即每次获取数据库连接时，都会创建一个全新的连接，而不是从连接池中复用一个已存在的连接。这与传统连接池复用连接的机制完全不同。</div>
          </div>
          <div class="card-source">来源: 「1. UnpooledDataSource 概述」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在MyBatis的配置文件中，如何指定使用`UnpooledDataSource`作为数据源？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过在MyBatis的配置文件中设置`<dataSource>`元素的`type`属性为`"UNPOOLED"`来指定使用`UnpooledDataSource`。同时需要配置driver、url、username和password等数据库连接属性。</div>
          </div>
          <div class="card-source">来源: 「3. 如何配置」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">应用</div>
          <div class="card-question">`UnpooledDataSource`主要适用于哪些具体场景？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">应用</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`UnpooledDataSource`通常用于轻量级的开发和测试环境，以便于快速配置和调试；也常用于演示MyBatis基本功能的场景，这些场景通常不涉及性能和生产级的需求。</div>
          </div>
          <div class="card-source">来源: 「2. 使用场景」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">与HikariCP、Druid等成熟的连接池相比，`UnpooledDataSource`在性能方面有何劣势？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">由于`UnpooledDataSource`每次请求都会创建新的数据库连接，没有连接复用的特性，导致其性能较差，尤其是在高负载的生产环境下，频繁创建和销毁连接会带来巨大的开销。</div>
          </div>
          <div class="card-source">来源: 「4. 与其他连接池的比较」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`UnpooledDataSource`缺少哪些生产级连接池所具备的高级功能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`UnpooledDataSource`不提供连接池的高级功能，例如连接复用、连接池大小限制、空闲连接检测等。这些功能对于保证生产环境下连接管理的稳定性和高效性至关重要。</div>
          </div>
          <div class="card-source">来源: 「4. 与其他连接池的比较」部分</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
